const express = require('express');

const bodyParse = require('body-parser');
//创建服务器
const app =express();
app.use(fn ({a:1}));

function fn (obj) {
  return function(req,res,next) {
    if(obj.a == 1) {
      console.log(req.url)
    } else {
      console.log(req.method);
    }
    
    next();
  }
}
//接收请求
app.get('/',(req,res)=>{
  //接收参数
  res.send('ok')
})
//监听端口
app.listen(3000);
console.log('服务器启动成功')